#include<iostream>
using namespace std;
int main(){
	int a , b ,i , j , k ,n,arr[6][6] = {0};
	for(i = 1; i <= 5; i++){
		for(j = 1; j <= 5; j++){
			cin >> arr[i][j];
		}
	}
	cin >> a >> b;
		for(j = 1; j <= 5; j++){
			k = arr[a][j];
			arr[a][j] = arr[b][j];
		arr[b][j] = k;	
		}
	for(i = 1; i <= 5; i++){
		for(j = 1; j <= 5; j++){
		cout << arr[i][j] << ' '; 
	}
	cout << endl;
}
	return 0;
}
